﻿using System;
using Entity;
using BLL;
using BLL.Access;
using Web.Class;
using DevExpress.Web;
using System.Data;
using System.IO;
using System.Web;
using YXYLCommon;

namespace Web.Pages.YongShui._1.JiChuXX
{
    public partial class YongHuZLSC : System.Web.UI.Page
    {
        #region 属性
        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtYongHuXX
        {
            get
            {
                return ViewState["dtYongHuXX"] as DataTable;
            }
            set
            {
                ViewState["dtYongHuXX"] = value;
            }
        }
        #endregion
        
        #region 变量
        /// <summary>
        /// 存储过程调用
        /// </summary>
        SpHelper _sphelper = new SpHelper();
        /// <summary>
        /// 用户信息BLL 自来水
        /// </summary>
        YS_YG_YONGHUXXBLL BllYongHu = new YS_YG_YONGHUXXBLL();

        /// <summary>
        /// 用户信息BLL 水资源
        /// </summary>
        QS_YG_YONGHUXXBLL _QSYHXXBLL = new QS_YG_YONGHUXXBLL();

        SYS_UPLOADProcess uploadbll = new SYS_UPLOADProcess();

        SYS_UPLOAD_LOGBLL uploadLOGBLL = new SYS_UPLOAD_LOGBLL();
         /// <summary>
        /// 管理块BLL
        /// </summary>
        YS_JX_GUANLIKBLL _YS_JX_GUANLIKBLL = new YS_JX_GUANLIKBLL();
        /// <summary>
        /// 管理部门bll
        /// </summary>
        YS_JX_ZHANDIANBLL _YS_JX_ZHANDIANBLL = new YS_JX_ZHANDIANBLL();
        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();

        /// <summary>
        /// 行政区
        /// </summary>
        QS_JX_XINGZHENGQBLL XZQ = new QS_JX_XINGZHENGQBLL();
        #endregion
        
        #region 事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
                InitControl();
                if (BusinessTool.WType == 0)
                {
                    InitData();
                    gvList.Columns.RemoveAt(3);
                }
                else
                {
                    LabGM.Text = "行政区:";
                    LoadXZQ();
                    labGuanLiK.Visible = false;
                    cmbGuanLiK.Visible = false;
                    gvList.Columns.RemoveAt(2);
                }
                this.gvList.DataSource = this.dtYongHuXX;
                this.gvList.DataBind();
            }
            else 
            {
                this.gvList.DataSource = this.dtYongHuXX;
                this.gvList.DataBind();
            
            }
            if (gvList.VisibleRowCount > 0)
                gvList.FocusedRowIndex = 0;
            //ASPxDropDownEdit1.Text = "Chrome;Safari";

        }

        /// <summary>
        /// 加载行政区
        /// </summary>
        private void LoadXZQ()
        {
            DataTable dt = XZQ.SelectQS_JX_XINGZHENGQsDynamic("I_JLZT=0", null);
            dt.Rows.InsertAt(dt.NewRow(), 0);
            dt.Rows[0]["S_XINGZHENGQH"] = 0;
            dt.Rows[0]["S_XINGZHENGQM"] = "全部";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cmbGuanLiBM.Items.Add(dt.Rows[i]["S_XINGZHENGQM"].ToString(), dt.Rows[i]["S_XINGZHENGQH"]);
            }
            cmbGuanLiBM.SelectedIndex = 0;
        }

        protected void SearchByUserTapWater()
        {
            string v_zhandian = "", v_guanlikuai = "",fileType="",isFile="";
            int userId = 0;
            if (cmbGuanLiBM.Value != null)
            {
                v_zhandian = cmbGuanLiBM.Value.ToString();
            }
            if (cmbGuanLiK.Value != null)
            {
                v_guanlikuai = cmbGuanLiK.Value.ToString();
            }
            if (ASPxComboBox2.Value != null)
                isFile = ASPxComboBox2.Value.ToString() == "0" ? "1" : "2";


            //if (txtList.Text != null && txtList.Text.Length > 0)
            //{
            //    var t = txtList.Text.Substring(0, txtList.Text.Length - 1);
            //  // fileType = GetSelectedValue(t);
            //   // fileType = fileType.Substring(0, fileType.Length - 1);
           // }
            for (int i = 0; i < chkList.Items.Count; i++)
            {
                if (chkList.Items[i].Selected)
                {
                    fileType = fileType + chkList.Items[i].Value.ToString() + ",";
                }
            }
            if (fileType.Length > 0)
            {
                fileType = fileType.Substring(0, fileType.Length - 1);
            }
            var s= BusinessTool.CurrentUserGroup(LoginInfo.CurrentUser.UserID);
            if (s.Select("roleid=9001").Length > 0)
                userId = LoginInfo.CurrentUser.UserID;
            this.dtYongHuXX = _SpHelper.P_YSCX_YHXXCXX(v_zhandian, v_guanlikuai, fileType, isFile,userId).Tables[0];
            gvList.DataSource = this.dtYongHuXX;
            gvList.DataBind();
        }

        protected void SearchByUserGroundWater()
        {

            string xzq = cmbGuanLiBM.Text != "全部" ? cmbGuanLiBM.Value.ToString() : null;
            string fileType="",isFile="";
            int userId = 0;

            if (ASPxComboBox2.Value != null)
                isFile = ASPxComboBox2.Value == "0" ? "1" : "2";

            for (int i = 0; i < chkList.Items.Count; i++)
            {
                if (chkList.Items[i].Selected)
                {
                    fileType = fileType + chkList.Items[i].Value.ToString() + ",";
                }
            }
            if (fileType.Length > 0)
            {
                fileType = fileType.Substring(0, fileType.Length - 1);
            }
            var s = BusinessTool.CurrentUserGroup(LoginInfo.CurrentUser.UserID);
            if (s.Select("roleid=9001").Length > 0)
                userId = LoginInfo.CurrentUser.UserID;
            this.dtYongHuXX = _SpHelper.P_QSCX_YONGHUXXCXX(BusinessTool.WType, BusinessTool.GetSLYMorZWNY(1, BusinessTool.WType), null, xzq, "", null, "", 0,fileType,isFile,userId).Tables[0];
            gvList.DataSource = this.dtYongHuXX;
            gvList.DataBind();
 
        }

        private void InitData()
        {
            int userid = LoginInfo.CurrentUser.UserID;
            string username = LoginInfo.CurrentUser.UserName;

            gvList.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;

            //管理部门
            DataTable dtGuanLiBM = _YS_JX_ZHANDIANBLL.SelectYS_JX_ZHANDIANsAll();
            dtGuanLiBM.Rows.InsertAt(dtGuanLiBM.NewRow(), dtGuanLiBM.Rows.Count);
            dtGuanLiBM.Rows[dtGuanLiBM.Rows.Count - 1]["ID"]="0";
            dtGuanLiBM.Rows[dtGuanLiBM.Rows.Count - 1]["S_ZHANDIANMC"] = "全部";
            dtGuanLiBM.Rows.Remove(dtGuanLiBM.Rows[0]);
            for (int i = 0; i < dtGuanLiBM.Rows.Count; i++)
            {
                if (dtGuanLiBM.Rows[i]["S_ZHANDIANMC"].ToString() != "中心")
                {
                    cmbGuanLiBM.Items.Add(dtGuanLiBM.Rows[i]["S_ZHANDIANMC"].ToString(), dtGuanLiBM.Rows[i]["S_ZHANDIANBH"].ToString());
                }
            }
            cmbGuanLiBM.SelectedIndex = 0;
            //根据操作人加载管理部门(站点)
            string zdbh = BusinessTool.ZHANDIANBH();
            //管理块
            //DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic((zdbh == "00" || zdbh == "51") ? "S_ZHANDIAN<>'00'" : string.Format("S_ZHANDIAN={0}", zdbh), null);
            //for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
            //{
            //    cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
            //}
            
            DataTable dtZhanDian = BusinessTool.GetTextAndValue("View_AS_UserInfo", "ZHANDIANBH", "ROLEID", null, string.Format("USERID={0}", userid)).Tables[0];
            string zhandian = dtZhanDian.Rows[0]["TEXT"].ToString();//站点
            string roleid = dtZhanDian.Rows[0]["VALUE"].ToString();//9001 业务员，3001 办事处主任
            if (roleid == "9001")
            {
                if (zhandian!="00")
                {
                    cmbGuanLiBM.Enabled = false;
                    
                    cmbGuanLiBM.Value = zhandian;
                    
                    //管理块
                    DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", zhandian), null);
                    for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                    {
                        cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                    }
                }
            }
            else if (roleid == "3001" || roleid == "4001")
            {
                if (!(zdbh == "00" || zdbh == "51"))
                {
                    cmbGuanLiBM.Enabled = false;
                }
                
                cmbGuanLiBM.Value = zhandian;
                //管理块
                DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", zhandian), null);
                for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                {
                    cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                }
            }
            else {
                cmbGuanLiK.Items.Clear();
                cmbGuanLiK.Items.Add("全部", "");
                cmbGuanLiK.SelectedIndex = 0;
                string glbm_now = cmbGuanLiBM.Value != null ? cmbGuanLiBM.Value.ToString() : "全部";
                InitDataAgain(glbm_now);
            }
              
        }

        protected void UpLoadFile_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {

            if ((!hdCollection.Contains("cllb") || hdCollection.Get("cllb") == null || hdCollection.Get("cllb").ToString() == "-1") && BusinessTool.WType != 1 && BusinessTool.WType != 2)
            {
                e.CallbackData = "-2";
            }
            else
            {
                e.CallbackData = SavePostedFile(e.UploadedFile);                
            }            
        }

        protected void Call_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        
        
        {            
            if (e.Parameter == "select")
            {
                string code = "-1";
                string msg = "";
                string yonghuh = hdCollection.Get("yonghuh").ToString();
                if (yonghuh.Trim().Length > 0)
                {
                    DataTable dt = new DataTable();
                    if (BusinessTool.WType == 0)
                    {
                        dt = BllYongHu.SelectYS_YG_YONGHUXXesDynamic("S_YONGHUH='" + yonghuh + "' and i_jlzt=0 ", "", null);
                    }
                    else //if (BusinessTool.WType == 2)
                    {
                        dt = _QSYHXXBLL.SelectQS_YG_YONGHUXXesDynamic("S_YONGHUH='" + yonghuh + "' and i_jlzt=0 ", "", null);
                    }
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        code = "1";
                        msg = dt.Rows[0]["S_YONGHUM"] + "|" + dt.Rows[0]["S_DIZHI"] + "|" + dt.Rows[0]["S_YONGHUH"];
                    }
                    else
                    {
                        code = "0";
                    }

                }
                if (code == "1")
                {
                    DataSet ds = _sphelper.P_YS_CX_CAILIAOXX(" and S_YONGHUBH='" + hdCollection.Get("yonghuh") + "'  and i_jlzt>=0 ", 0);
                    if (ds.Tables[0].Rows.Count == 0)
                        msg = msg + "|该用户尚未上传过材料";
                    else
                    {
                      //  var dt = _sphelper.P_YS_LH_CAILIAOLBCX(" and I_CAILIAOBH not in (1,2,3,4,5,14)").Tables[0];
                        msg = msg + "|该用户已经上传了" + ds.Tables[0].Rows.Count.ToString() + "种材料";//还有" + (dt.Rows.Count - ds.Tables[0].Rows.Count).ToString() + "种材料没有上传";
                    }
                }
                e.Result = e.Parameter + "|" + code + "|" + msg + "|" + LoginInfo.CurrentUser.UserID;
            }
            else if (e.Parameter == "save")
            {
                if (Session["gaopai"] != null)
                {
                    DataTable uploadtable = Session["gaopai"] as DataTable;
                    SYS_UPLOAD upload = new SYS_UPLOAD();
                    upload.I_SUOSHUMK = 1;
                    upload.I_TYPE = BusinessTool.WType;
                    upload.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
                    upload.S_LAIHANBH = null;
                    upload.S_YONGHUBH = hdCollection.Get("yonghuh").ToString();
                    upload.D_CAOZUORQ = DateTime.Now;
                    foreach (DataRow dr in uploadtable.Rows)
                    {
                        upload.ID = 0;
                        ///证件类型的文件只和用户相关，更新

                        DataTable shangchuan = uploadbll.SelectSYS_UPLOADsDynamic(string.Format(" S_YONGHUBH='{0}' and I_WENJIANLX={1} ", hdCollection.Get("yonghuh").ToString(), dr["value"]), "", null);
                        if (shangchuan != null && shangchuan.Rows.Count > 0)
                        {
                            upload.ID = Convert.ToInt32(shangchuan.Rows[0]["ID"]);
                        }

                        upload.S_WENJIANMC = dr["name"].ToString();
                        upload.S_WENJIANLJ = dr["path"].ToString();
                        upload.I_WENJIANLX = Convert.ToInt32(dr["value"]);
                        upload.I_SHANGCHUANLB = Convert.ToInt32(dr["type"]);
                        uploadbll.InsertOrUpdate(upload);
                        SYS_UPLOAD_LOG uploadlog = new SYS_UPLOAD_LOG();
                        uploadlog.D_CAOZUORQ = DateTime.Now;
                        uploadlog.I_CAOZUOR = LoginInfo.CurrentUser.UserID;
                        uploadlog.I_JLZT = 0;
                        uploadlog.I_TYPE = BusinessTool.WType;
                        uploadlog.I_WENJIANLX = Convert.ToInt32(dr["value"]);
                        uploadlog.ID = 0;
                        uploadlog.S_WENJIANLJ = dr["path"].ToString();
                        uploadlog.S_WENJIANMC = dr["name"].ToString();
                        uploadlog.S_YONGHUBH = hdCollection.Get("yonghuh").ToString();
                        new SYS_LOGBLL().Log<SYS_UPLOAD>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "月调整流程-月调整登记", OperateState.Modify, upload, null);
                        uploadLOGBLL.InsertOrUpdate(uploadlog);
                        

                    }
                    Session["gaopai"] = null;
                }
                e.Result = e.Parameter + "|" + "" + "|" + "";
            }
        }
        #endregion
        
        #region 方法
        private void InitControl()
        {
            this.hdCollection.Set("wtype",BusinessTool.WType);
            txtYongHuH.Focus();
            DataTable dt = new DataTable();
            if (BusinessTool.WType == 0)
            {
                 dt = _sphelper.P_YS_LH_CAILIAOLBCX(" and I_CAILIAOBH not in (1,2,3,4,5,14,15,16,17,18,19,20,21,22)").Tables[0];
            }
            else
            {
                dt.Columns.Add("S_CAILIAOMC");
                dt.Columns.Add("I_CAILIAOBH");
                dt.Rows.Add(dt.NewRow());
                dt.Rows[0][0] = "其他";
            }

            cmCaiLiaoLB.DataSource = dt;
            cmCaiLiaoLB.TextField = "S_CAILIAOMC";
            cmCaiLiaoLB.ValueField = "I_CAILIAOBH";
            cmCaiLiaoLB.DataBind();
            if (BusinessTool.WType == 0)
                cmCaiLiaoLB.Items.Insert(0, new ListEditItem("请选择上传材料类别", "-1"));
            cmCaiLiaoLB.SelectedIndex = 0;

            if (BusinessTool.WType == 0)
            {
                if (dt.Rows.Count > 0)
                {
                    ////缩写
                    dt.Columns.Add("S_CAILIAOMCSX");

                    dt.Rows[0]["S_CAILIAOMCSX"] = "项目规划许材料";
                    dt.Rows[1]["S_CAILIAOMCSX"] = "用水情况资料";
                    dt.Rows[2]["S_CAILIAOMCSX"] = "水平衡测试资料";
                    dt.Rows[3]["S_CAILIAOMCSX"] = "用水分类情况表";
                    dt.Rows[4]["S_CAILIAOMCSX"] = "负责人身份证明";
                    dt.Rows[5]["S_CAILIAOMCSX"] = "申请人身份证复印件";
                    dt.Rows[6]["S_CAILIAOMCSX"] = "营业执照复印件";

                    dt.Rows.InsertAt(dt.NewRow(), 0);
                    dt.Rows[0][0] = "0";
                    dt.Rows[0]["S_CAILIAOMCSX"] = "全部";

                    this.chkList.DataSource = dt;
                    this.chkList.DataTextField = "S_CAILIAOMCSX";
                    this.chkList.DataValueField = "I_CAILIAOBH";
                    this.chkList.DataBind();

                }
            }
            if (BusinessTool.WType != 0)
            {
                zjl.Visible = false;
            }
        }

        /// <summary>
        /// 获取选中项的值
        /// </summary>
        /// <param name="selectText">选中的文本</param>
        /// <returns></returns>
        private string GetSelectedValue(string selectText)
        {
            //获取选中的特性分类的项，根据选中项匹配出像对应的值
            
            string str = "";

            string[] text = selectText.Split(',');

            for (int i = 0; i < text.Length; i++)
            {
                for (int j = 0; j < chkList.Items.Count; j++)
                {
                    if (chkList.Items[j].Text == text[i])
                    {
                        str += chkList.Items[j].Value + ",";
                    }
                }
            }
            return str;
        }
        private string SavePostedFile(UploadedFile uploadedFile)
        {
            string UploadDirectory = PageTools.GetUploadPath(BusinessTool.WType, "YHZL");

            if (!uploadedFile.IsValid)
            {
                return string.Empty;
            }
            if (!hdCollection.Contains("yonghuh") || hdCollection.Get("yonghuh")==null||hdCollection.Get("yonghuh").ToString().Length==0)
            {
                return "-1";
            }
            string fileName = Guid.NewGuid() + Path.GetExtension(uploadedFile.FileName);  //文件名
            string filePath = Path.Combine(Server.MapPath(UploadDirectory), fileName);    //文件完整物理路径
            uploadedFile.SaveAs(filePath);
             int cllb=0;
            string lbmc="";
             if (hdCollection.Contains("cllb"))
                 cllb = hdCollection.Get("cllb").GetNoNullInt32();
             if (hdCollection.Contains("cllbmc"))
                 lbmc = hdCollection.Get("cllbmc").ToString();
             if (BusinessTool.WType != 0)
             {
                 lbmc=uploadedFile.FileName;                 
             }
            SYS_UPLOAD_LOG uploadlog = new SYS_UPLOAD_LOG();
            uploadlog.D_CAOZUORQ = DateTime.Now;
            uploadlog.I_CAOZUOR = LoginInfo.CurrentUser.UserID;
            uploadlog.I_JLZT = 0;
            uploadlog.I_TYPE = BusinessTool.WType == 0 ? 1 : 2;//1 自来水，2 水资源
            uploadlog.I_WENJIANLX = cllb;
            uploadlog.ID = 0;
            uploadlog.S_WENJIANLJ = UploadDirectory+fileName;
            uploadlog.S_WENJIANMC = lbmc;
            uploadlog.S_YONGHUBH = hdCollection.Get("yonghuh").ToString();
            uploadLOGBLL.InsertOrUpdate(uploadlog);

            SYS_UPLOAD upload = new SYS_UPLOAD();
            upload.I_SUOSHUMK = 1;
            upload.I_TYPE = BusinessTool.WType == 0 ? 1 : 2;//1 自来水，2 水资源
            upload.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
            upload.S_LAIHANBH = "";
            upload.S_YONGHUBH = hdCollection.Get("yonghuh").ToString();
            upload.D_CAOZUORQ = DateTime.Now;
            upload.I_WENJIANLX = cllb;
            upload.S_WENJIANMC = lbmc;
            upload.S_WENJIANLJ = UploadDirectory + fileName;
            upload.I_SHANGCHUANLB = 1;
            DataTable shangchuan = uploadbll.SelectSYS_UPLOADsDynamic(string.Format(" S_YONGHUBH='{0}' and I_WENJIANLX={1} ", hdCollection.Get("yonghuh").ToString(), cllb), "", null);
            if (shangchuan != null && shangchuan.Rows.Count > 0)
            {
                upload.ID = Convert.ToInt32(shangchuan.Rows[0]["ID"]);
            }
            uploadbll.InsertOrUpdate(upload);
            return filePath;
        }
        #endregion

        protected void gvLH_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            if (hdCollection.Contains("yonghuh"))
            {
                DataSet ds = new DataSet();
                if (BusinessTool.WType == 0)
                    ds = _sphelper.P_YS_CX_CAILIAOXX(" and S_YONGHUBH='" + hdCollection.Get("yonghuh") + "'  AND i_jlzt>=0", 0);
                else
                    //comment by guodengjie 20170816
                   ds = _sphelper.P_YS_CX_MATERIALDETAILED(hdCollection.Get("yonghuh").ToString());
                var fileTable = ds.Tables[0];
                foreach (DataRow row in fileTable.Rows)
                {
                    var host = Request.Url.ToString().Replace("http://","").Split('/')[0]; 
                    row["S_WENJIANLJ"] = "http://"+ host + "/" + row["S_WENJIANLJ"];
                    var filePath = row["S_WENJIANLJ"].ToString().ToLower();
                    if (filePath.EndsWith("jpg") || filePath.EndsWith("png") || filePath.EndsWith("jpeg") ||
                        filePath.EndsWith("bmp"))
                    {
                        row["S_WENJIANLJ"] = "http://" + host + "/ImageView.html?img=" + row["S_WENJIANLJ"];
                    }
                }
                gvLH.DataSource = ds.Tables[0];
                gvLH.DataBind();

            }
        }

        protected void BtnGPSC_Click(object sender, EventArgs e)
        {
            
        }

        protected void cmbGuanLiBM_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbGuanLiK.Items.Clear();
            cmbGuanLiK.Items.Add("全部", "");
            cmbGuanLiK.SelectedIndex = 0;
            string glbm_now = cmbGuanLiBM.Value != null ? cmbGuanLiBM.Value.ToString() : "全部";
            InitDataAgain(glbm_now);
        }

        /// <summary>
        /// 再次根据管理部门初始化查询条件
        /// </summary>
        /// <param name="glbm">管理部门</param>
        private void InitDataAgain(string glbm)
        {
            //管理块
            if (glbm != "全部")
            {
                DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", glbm), null);
                for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                {
                    cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                }
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {

            if (BusinessTool.WType == 0)
            {
                //string a = txtList.Text;
                SearchByUserTapWater();
            }
            else
            {
                SearchByUserGroundWater();
            }



            if (gvList.VisibleRowCount > 0)
            {
                gvList.FocusedRowIndex = -1;
                gvList.FocusedRowIndex = 0;
            }
            else
            {
                txtYongHuH.Text = "";
                txtYongHuM.Text = "";
                txtDiZhi.Text = "";
                cmCaiLiaoLB.SelectedIndex = 0;
                gvLH.DataSource = null;
                gvLH.DataBind();
            }
            aspXCount.Text = "共" + this.dtYongHuXX.Rows.Count.ToString() + "条";

        }

        protected void cmbGuanLiK_Callback(object sender, CallbackEventArgsBase e)
        {
           
            cmbGuanLiK.Items.Clear();
            cmbGuanLiK.Items.Add("全部", "");
            cmbGuanLiK.SelectedIndex = 0;
            string glbm_now = cmbGuanLiBM.Value != null ? cmbGuanLiBM.Value.ToString() : "全部";
            InitDataAgain(glbm_now);
        }
    }
}